package com.yq.testmodule.hook

import android.content.Intent
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import com.alibaba.android.arouter.facade.annotation.Route
import com.fmt.mvi.learn.gobal.log
import com.yq.testmodule.TestSkinActivity
import config.TEST_HOOK

/**
 * @author: user
 * @date: 2023/3/14
 */
@Route(path = TEST_HOOK)
class HookTestActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {
            Column {

                Button(onClick = {
                    loadHook()
                }) {
                    Text("加载hook")
                }

                Button(onClick = {
                    startActivity()
                }) {
                    Text("跳转未注册Activity")
                }
                Button(onClick = {
                    startNormalActivity()
                }) {
                    Text("跳转正常activity")
                }
            }
        }
    }


    fun loadHook() {
        try {
            HookAMS.hookAMS(this)
//            HookUtil.hookAMS()
//            HookUtil.hookHandler()
        } catch (e: java.lang.Exception) {
            e.log()
        }
    }

    fun startActivity() {
        startActivity(Intent(this, NoRegisterActivity::class.java))
    }

    fun startNormalActivity() {
        startActivity(Intent(this, TestSkinActivity::class.java))
    }
}